package org.sbpme.instance.impl;

import java.io.Serializable;
import java.util.HashMap;

import org.sbpme.instance.Instance;
import org.sbpme.process.model.Process;
import org.sbpme.process.model.node.Activity;

public class InstanceImpl implements Instance, Serializable {

	private static final long serialVersionUID = 8543422382764390192L;

	// Serialization Part
	private String processId;
	private String currentActivityId;
	private HashMap<String, Serializable> variableInstances;

	private Process process;
	private Activity currentActivity;

	public InstanceImpl(Process process) {
		this.process = process;
		this.variableInstances = new HashMap<String, Serializable>();
	}

	public Activity getCurrentActivity() {
		return currentActivity;
	}

	public void setCurrentActivity(Activity currentActivity) {
		this.currentActivity = currentActivity;
	}

	public Process getProcess() {
		return this.process;
	}

	public void setVariableValue(String name, Serializable value) {
		variableInstances.put(name, value);
	}

	public Serializable getVariableValue(String name) {
		return variableInstances.get(name);
	}

	public Serializable getInstanceState() {
		return this;
	}

	public void setIntanceState(Serializable serializable) {
		InstanceImpl instanceImpl = (InstanceImpl) serializable;
		this.variableInstances = instanceImpl.variableInstances;
	}
}
